/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.login.plugin.profile.view;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.text.TextPaint;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import com.qihoo.gamecenter.sdk.common.IDispatcherCallback;
import com.qihoo.gamecenter.sdk.common.i.q;
import com.qihoo.gamecenter.sdk.login.plugin.d.a;
import com.qihoo.gamecenter.sdk.login.plugin.h.e;
import com.qihoo.gamecenter.sdk.login.plugin.h.f;
import com.qihoo.gamecenter.sdk.login.plugin.profile.a.b;
import java.io.File;
import org.json.JSONException;
import org.json.JSONObject;

public class ShowProfileDialog extends RelativeLayout {
    private Activity c;
    private String d;
    private Intent e;
    private com.qihoo.gamecenter.sdk.login.plugin.f.a f;
    private RelativeLayout g;
    private ImageView h;
    private Bitmap i;
    private TextView j;
    private TextView k;
    private Button l;
    private boolean m = false;
    public File a = new File(Environment.getExternalStorageDirectory() + "/360GameSDK/360head_protarit.jpg");
    private Handler n = new Handler() {
        public void handleMessage(Message paramMessage) {
            Object localObject = paramMessage.obj;
            if (localObject != null) {
                Bitmap localBitmap = (Bitmap) localObject;
                ShowProfileDialog.this.a(localBitmap);
            }
            if (ShowProfileDialog.a(ShowProfileDialog.this) == null)
                return;
            ShowProfileDialog.a(ShowProfileDialog.this).setVisibility(8);
        }
    };
    private View.OnClickListener o = new View.OnClickListener() {
        public void onClick(View paramView) {
            if (paramView == ShowProfileDialog.b(ShowProfileDialog.this)) {
                ShowProfileDialog.c(ShowProfileDialog.this);
            }
            else if (paramView == ShowProfileDialog.d(ShowProfileDialog.this)) {
                ShowProfileDialog.e(ShowProfileDialog.this);
            }
            else if (paramView == ShowProfileDialog.f(ShowProfileDialog.this)) {
                ShowProfileDialog.g(ShowProfileDialog.this);
            }
            else {
                if (paramView != ShowProfileDialog.h(ShowProfileDialog.this))
                    return;
                ShowProfileDialog.i(ShowProfileDialog.this);
            }
        }
    };
    private View.OnClickListener p = new View.OnClickListener() {
        public void onClick(View paramView) {
            Object localObject = paramView.getTag();
            if ((localObject == null) || (!(localObject instanceof Integer)))
                return;
            ShowProfileDialog.a(ShowProfileDialog.this, ((Integer) localObject).intValue());
        }
    };
    private UploadProgress q;
    private ImageView r;
    public String b;
    private static final int[] s = { 1073741859, 1073741860, 1073741861, 1073741862 };

    public ShowProfileDialog(Context paramContext) {
        super(paramContext);
    }

    public ShowProfileDialog(Activity paramActivity, String paramString, Intent paramIntent) {
        super(paramActivity);
        this.c = paramActivity;
        this.d = paramString;
        this.e = paramIntent;
        this.f = com.qihoo.gamecenter.sdk.login.plugin.f.a.a(this.c);
        this.m = paramIntent.getBooleanExtra("is_from_login", false);
        if (this.m)
            com.qihoo.gamecenter.sdk.login.plugin.profile.a.a(paramActivity,
                    com.qihoo.gamecenter.sdk.login.plugin.h.d.d(), true);
        File localFile = this.a.getParentFile();
        if (!(localFile.exists()))
            localFile.mkdirs();
        a();
    }

    private void a() {
        setBackgroundDrawable(this.f.a(-1073741797));
        setGravity(17);
        a(this.c);
        b();
    }

    private void b() {
        boolean bool = f.b(this.c);
        if (!(bool)) {
            if (this.q != null)
                this.q.setVisibility(8);
            return;
        }
        com.qihoo.gamecenter.sdk.login.plugin.profile.a.a locala = new com.qihoo.gamecenter.sdk.login.plugin.profile.a.a(
                this.c);
        Intent localIntent = new Intent();
        locala.a(this.c, localIntent, new IDispatcherCallback() {
            public void onFinished(String paramString) {
                e.a("Plugin.ShowProfileDialog", new Object[] { "GetUserInfoTask onFinished : " + paramString });
                int i = 0;
                try {
                    JSONObject localJSONObject = new JSONObject(paramString);
                    Object localObject;
                    if (localJSONObject.optInt("errno", 0) == 0) {
                        localObject = localJSONObject.getJSONObject("data");
                        String str = ((JSONObject) localObject).optString("head_pic", "");
                        ShowProfileDialog.this.a(str);
                    }
                    else {
                        i = 1;
                        localObject = localJSONObject.optString("errmsg", "");
                        q.a(ShowProfileDialog.j(ShowProfileDialog.this), (String) localObject, 0, 80);
                    }
                } catch (JSONException localJSONException) {
                    i = 1;
                }
                if ((i == 0) || (ShowProfileDialog.a(ShowProfileDialog.this) == null))
                    return;
                ShowProfileDialog.a(ShowProfileDialog.this).setVisibility(8);
            }
        });
    }

    protected void a(String paramString) {
        com.qihoo.gamecenter.sdk.login.plugin.profile.a.a(this.c, paramString, this.n);
    }

    protected void a(Bitmap paramBitmap) {
        this.h.setBackgroundDrawable(new BitmapDrawable(paramBitmap));
        if ((this.i != null) && (!(this.i.isRecycled())))
            this.i.recycle();
        this.i = paramBitmap;
    }

    private void a(Context paramContext) {
        RelativeLayout.LayoutParams localLayoutParams = new RelativeLayout.LayoutParams(-1, -2);
        localLayoutParams.topMargin = f.a(paramContext, 16.0F);
        localLayoutParams.bottomMargin = f.a(paramContext, 18.0F);
        this.g = new RelativeLayout(paramContext);
        this.g.setLayoutParams(localLayoutParams);
        addView(this.g);
        c(paramContext);
        d(paramContext);
        b(paramContext);
    }

    private void b(Context paramContext) {
        int i1 = f.a(this.c, 4.0F);
        int i2 = f.a(paramContext, 10.0F);
        int i3 = f.a(paramContext, 10.0F);
        int i4 = f.a(paramContext, 19.0F);
        int i5 = f.a(paramContext, 12.0F);
        RelativeLayout.LayoutParams localLayoutParams = new RelativeLayout.LayoutParams(f.a(this.c, 32.0F), f.a(this.c,
                43.0F));
        localLayoutParams.topMargin = 0;
        localLayoutParams.rightMargin = 0;
        this.r = new ImageView(paramContext);
        localLayoutParams.addRule(10, -1);
        localLayoutParams.addRule(11, -1);
        this.r.setLayoutParams(localLayoutParams);
        this.r.setPadding(i2, i4, i3, i5);
        this.r.setScaleType(ImageView.ScaleType.FIT_XY);
        this.f.a(this.r, 1073741833, 1073741834, 1073741834);
        addView(this.r);
        this.r.setOnClickListener(this.o);
    }

    private void c(Context paramContext) {
        TextView localTextView = new TextView(paramContext);
        RelativeLayout.LayoutParams localLayoutParams = new RelativeLayout.LayoutParams(-2, -2);
        localLayoutParams.addRule(14, -1);
        localLayoutParams.topMargin = f.a(paramContext, 8.0F);
        localTextView.setLayoutParams(localLayoutParams);
        localTextView.setId(a.b.ordinal());
        localTextView.setGravity(17);
        localTextView.setTextSize(1, com.qihoo.gamecenter.sdk.login.plugin.h.c.g);
        localTextView.setTextColor(Color.parseColor("#FF7F16"));
        TextPaint localTextPaint = localTextView.getPaint();
        localTextPaint.setFakeBoldText(true);
        localTextView.setText(com.qihoo.gamecenter.sdk.login.plugin.d.a(d.a.dV));
        this.g.addView(localTextView, localLayoutParams);
    }

    private void d(Context paramContext) {
        RelativeLayout localRelativeLayout = new RelativeLayout(paramContext);
        RelativeLayout.LayoutParams localLayoutParams1 = new RelativeLayout.LayoutParams(f.a(paramContext, 272.0F), -2);
        localLayoutParams1.bottomMargin = f.a(paramContext, 10.0F);
        localLayoutParams1.topMargin = f.a(paramContext, 14.0F);
        localLayoutParams1.addRule(3, a.b.ordinal());
        localLayoutParams1.addRule(14, -1);
        localRelativeLayout.setId(a.c.ordinal());
        localRelativeLayout.setLayoutParams(localLayoutParams1);
        this.g.addView(localRelativeLayout, localLayoutParams1);
        int i1 = f.a(paramContext, 60.0F);
        this.h = new ImageView(paramContext);
        this.h.setScaleType(ImageView.ScaleType.FIT_XY);
        RelativeLayout.LayoutParams localLayoutParams2 = new RelativeLayout.LayoutParams(i1, i1);
        localLayoutParams2.addRule(14, -1);
        localLayoutParams2.addRule(9, -1);
        localLayoutParams2.addRule(10, -1);
        Drawable localDrawable1 = this.f.a(1073741858);
        Drawable localDrawable2 = this.f.a(1073741863);
        this.h.setImageDrawable(localDrawable1);
        this.h.setBackgroundDrawable(localDrawable2);
        localRelativeLayout.addView(this.h, localLayoutParams2);
        this.j = new TextView(paramContext);
        i1 = f.a(paramContext, 110.0F);
        int i2 = f.a(paramContext, 38.0F);
        int i3 = f.a(paramContext, 11.0F);
        int i4 = f.a(paramContext, 104.0F);
        int i5 = f.a(paramContext, 14.0F);
        int i6 = f.a(paramContext, 4.0F);
        RelativeLayout.LayoutParams localLayoutParams5 = new RelativeLayout.LayoutParams(i1, i2);
        localLayoutParams5.addRule(11, -1);
        localLayoutParams5.topMargin = i3;
        localLayoutParams5.rightMargin = i4;
        this.j.setGravity(16);
        this.j.setText(com.qihoo.gamecenter.sdk.login.plugin.d.a(d.a.df));
        this.j.setTextColor(-16777216);
        this.j.setTextSize(1, com.qihoo.gamecenter.sdk.login.plugin.h.c.j);
        this.j.setOnClickListener(this.o);
        this.j.setCompoundDrawablePadding(i6);
        this.f.a(this.j, 1073741864, 0, 0, 0);
        this.f.a(this.j, -1073741783, -1073741782, 0);
        this.j.setPadding(i5, 0, 0, 0);
        localRelativeLayout.addView(this.j, localLayoutParams5);
        this.k = new TextView(paramContext);
        i1 = f.a(paramContext, 104.0F);
        i2 = f.a(paramContext, 38.0F);
        i3 = f.a(paramContext, 11.0F);
        i4 = f.a(paramContext, 8.0F);
        i5 = f.a(paramContext, 4.0F);
        RelativeLayout.LayoutParams localLayoutParams4 = new RelativeLayout.LayoutParams(i1, i2);
        localLayoutParams4.addRule(11, -1);
        localLayoutParams4.topMargin = i3;
        this.k.setGravity(16);
        this.k.setText(com.qihoo.gamecenter.sdk.login.plugin.d.a(d.a.de));
        this.k.setTextColor(-16777216);
        this.k.setTextSize(1, com.qihoo.gamecenter.sdk.login.plugin.h.c.j);
        this.k.setOnClickListener(this.o);
        this.k.setCompoundDrawablePadding(i5);
        this.f.a(this.k, 1073741868, 0, 0, 0);
        this.f.a(this.k, -1073741779, -1073741778, 0);
        this.k.setPadding(i4, 0, 0, 0);
        localRelativeLayout.addView(this.k, localLayoutParams4);
        i1 = f.a(paramContext, 76.0F);
        i2 = f.a(paramContext, 62.0F);
        RelativeLayout.LayoutParams localLayoutParams3 = new RelativeLayout.LayoutParams(-1, i1);
        LinearLayout localLinearLayout = new LinearLayout(paramContext);
        localLinearLayout.setOrientation(0);
        localLayoutParams3.topMargin = i2;
        localLayoutParams3.addRule(14, -1);
        this.f.a(localLinearLayout, -1073741781);
        a(localLinearLayout, paramContext);
        localRelativeLayout.addView(localLinearLayout, localLayoutParams3);
        this.l = new Button(paramContext);
        i1 = f.a(paramContext, 38.0F);
        i2 = f.a(paramContext, 154.0F);
        localLayoutParams3 = new RelativeLayout.LayoutParams(-1, i1);
        localLayoutParams3.addRule(11, -1);
        localLayoutParams3.topMargin = i2;
        this.l.setText(com.qihoo.gamecenter.sdk.login.plugin.d.a(d.a.dg));
        this.l.setTextColor(-1);
        this.l.setTextSize(1, com.qihoo.gamecenter.sdk.login.plugin.h.c.l);
        this.l.setOnClickListener(this.o);
        this.f.a(this.l, -1073741764, -1073741763, -1073741763);
        localRelativeLayout.addView(this.l, localLayoutParams3);
    }

    private void a(LinearLayout paramLinearLayout, Context paramContext) {
        int i1 = f.a(paramContext, 20.0F);
        int i2 = f.a(paramContext, 19.0F);
        int i3 = f.a(paramContext, 32.0F);
        LinearLayout.LayoutParams localLayoutParams = new LinearLayout.LayoutParams(-2, -2);
        TextView localTextView = new TextView(paramContext);
        localLayoutParams.leftMargin = i1;
        localLayoutParams.rightMargin = i1;
        localLayoutParams.gravity = 16;
        localTextView.setText(com.qihoo.gamecenter.sdk.login.plugin.d.a(d.a.dh));
        localTextView.setTextColor(Color.parseColor("#666666"));
        localTextView.setTextSize(1, com.qihoo.gamecenter.sdk.login.plugin.h.c.i);
        paramLinearLayout.addView(localTextView, localLayoutParams);
        for (int i4 = 0; i4 < s.length; ++i4) {
            ImageView localImageView = new ImageView(paramContext);
            localImageView.setTag(Integer.valueOf(s[i4]));
            localLayoutParams = new LinearLayout.LayoutParams(i3, i3);
            localLayoutParams.gravity = 16;
            localLayoutParams.rightMargin = i2;
            this.f.a(localImageView, s[i4]);
            localImageView.setOnClickListener(this.p);
            paramLinearLayout.addView(localImageView, localLayoutParams);
        }
    }

    private void c() {
        if (this.m)
            com.qihoo.gamecenter.sdk.login.plugin.profile.a.a(this.c, com.qihoo.gamecenter.sdk.login.plugin.h.d.d(),
                    false);
        com.qihoo.gamecenter.sdk.login.plugin.profile.a.a(this.c);
    }

    private void d() {
        if (this.m)
            com.qihoo.gamecenter.sdk.login.plugin.profile.a.a(this.c, com.qihoo.gamecenter.sdk.login.plugin.h.d.d(),
                    false);
        com.qihoo.gamecenter.sdk.login.plugin.profile.a.a(this.c, this.a);
    }

    private void e() {
        if (this.m)
            b(null);
        else
            b(this.b);
    }

    private void b(String paramString) {
        if (this.c == null)
            return;
        com.qihoo.gamecenter.sdk.common.c localc = (com.qihoo.gamecenter.sdk.common.c) this.c;
        localc.execCallback(paramString);
        this.c.finish();
    }

    private void f() {
        if (this.m)
            b(null);
        else
            b(this.b);
        com.qihoo.gamecenter.sdk.login.plugin.profile.a.a(this.c, com.qihoo.gamecenter.sdk.login.plugin.h.d.d(), true);
    }

    private void a(int paramInt) {
        if (this.m)
            com.qihoo.gamecenter.sdk.login.plugin.profile.a.a(this.c, com.qihoo.gamecenter.sdk.login.plugin.h.d.d(),
                    false);
        File localFile = com.qihoo.gamecenter.sdk.login.plugin.profile.a.a(this.c, paramInt);
        c(localFile.getAbsolutePath());
    }

    private void c(String paramString) {
        if (!(f.a(this.c, com.qihoo.gamecenter.sdk.login.plugin.d.a(d.a.c), this.d)))
            return;
        b localb = new b(this.c);
        Intent localIntent = new Intent();
        e.a("Plugin.ShowProfileDialog", new Object[] { "uploadHeadPic : " + paramString });
        localIntent.putExtra("head_shot", paramString);
        localb.a(this.c, localIntent, new IDispatcherCallback() {
            public void onFinished(String paramString) {
                e.a("Plugin.ShowProfileDialog", new Object[] { "uploadHeadPic  onFinished : " + paramString });
                int i = 0;
                try {
                    JSONObject localJSONObject = new JSONObject(paramString);
                    if (localJSONObject.optInt("errno", 0) == 0) {
                        ShowProfileDialog.k(ShowProfileDialog.this);
                    }
                    else {
                        i = 1;
                        String str = localJSONObject.optString("errmsg", "");
                        q.a(ShowProfileDialog.j(ShowProfileDialog.this), str, 0, 80);
                    }
                } catch (JSONException localJSONException) {
                    i = 1;
                }
                ShowProfileDialog.this.b = paramString;
                if ((i == 0) || (ShowProfileDialog.a(ShowProfileDialog.this) == null))
                    return;
                ShowProfileDialog.a(ShowProfileDialog.this).setVisibility(8);
            }
        });
        if (this.q == null)
            return;
        this.q.setVisibility(0);
    }

    public void setProgress(UploadProgress paramUploadProgress) {
        this.q = paramUploadProgress;
    }
}